package io.shuttle.mbe.api

import io.shuttle.mbe.api.annotation.ChromeMinVersion
import io.shuttle.mbe.api.annotation.LowerEqMV2
import io.shuttle.mbe.api.annotation.PromiseStyleMinVersion
import io.shuttle.mbe.api.types.NumOrNumArr
import io.shuttle.mbe.api.types.StringOrStringArr
import io.shuttle.mbe.api.types.Value1Function
import io.shuttle.mbe.api.types.Value2Function
import io.shuttle.mbe.api.types.Value3Function
import io.shuttle.mbe.api.types.VoidFunction
import io.shuttle.mbe.api.types.Window
import io.shuttle.mbe.core.Promise

////////////////////
// Tabs
////////////////////
/**
 * Use the `Browser.tabs` API to interact with the browser's tab system. You can use this API to create, modify, and rearrange tabs in the browser.
 *
 * Permissions: The majority of the Browser.tabs API can be used without declaring any permission. However, the "tabs" permission is required in order to populate the url, title, and favIconUrl properties of Tab.
 */
interface Tabs {
    // The maximum number of times that captureVisibleTab can be called per second. captureVisibleTab is expensive and should not be called too often.
    // default is 2
    @ChromeMinVersion(92)
    val MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND: Int

    // An ID that represents the absence of a browser tab. default is -1
    @ChromeMinVersion(46)
    val TAB_ID_NONE: Int

    // An index that represents the absence of a tab index in a tab_strip.
    // default is  -1
    @ChromeMinVersion(123)
    val TAB_INDEX_NONE: Int

    // Captures the visible area of the currently active tab in the specified window. In order to call this method, the extension must have either the <all_urls> permission or the activeTab permission. In addition to sites that extensions can normally access, this method allows extensions to capture sensitive sites that are otherwise restricted, including chrome:-scheme pages, other extensions' pages, and data: URLs. These sensitive sites can only be captured with the activeTab permission. File URLs may be captured only if the extension has been granted file access.
    // @callback dataUrl - A data URL that encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML img element for display.
    @PromiseStyleMinVersion(88)
     fun captureVisibleTab(
        // The target window. Defaults to the current window.
        windowId: Number?,
        options: ExtensionTypes.ImageDetails?,
        callback: Value1Function<String>? = null
    ): Promise<String>

    // Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. For more details, see Content Script Messaging.
    // @return A port that can be used to communicate with the content scripts running in the specified tab. The port's runtime.Port event is fired if the tab closes or does not exist.
     fun connect(tabId: Number, connectInfo: ConnectInfo?): Runtime.Port

    // Creates a new tab.
    @PromiseStyleMinVersion(88)
     fun create(
        createProperties: CreateProperties,
        callback: Value1Function<Tab>? = null
    ): Promise<Tab>

    // Detects the primary language of the content in a tab.
    // @callback lauguage - An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The second to fourth columns are checked and the first non-NULL value is returned, except for Simplified Chinese for which zh-CN is returned. For an unknown/undefined language, und is returned.
    @PromiseStyleMinVersion(88)
     fun detectLanguage(
        // Defaults to the active tab of the current window.
        tabId: Number?,
        callback: Value1Function<String>? = null
    ): Promise<String>

    // Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
    // @callback tab - The discarded tab, if it was successfully discarded; undefined otherwise.
    @PromiseStyleMinVersion(88)
    @ChromeMinVersion(54)
     fun discard(
        // The ID of the tab to be discarded. If specified, the tab is discarded unless it is active or already discarded. If omitted, the browser discards the least important tab. This can fail if no discardable tabs exist.
        tabId: Number?,
        callback: Value1Function<Tab?>? = null
    ): Promise<Tab?>

    // Duplicates a tab.
    // @callback tab - Details about the duplicated tab. The url, pendingUrl, title and favIconUrl properties are only included on the tabs.Tab object if the extension has the "tabs" permission or has host permissions for the page.
    @PromiseStyleMinVersion(88)
     fun duplicate(
        // The ID of the tab to duplicate.
        tabId: Number,
        callback: Value1Function<Tab?>? = null
    ): Promise<Tab?>

    // Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
    // @callback result - The result of the script in every injected frame.
    @PromiseStyleMinVersion(88)
    @LowerEqMV2
    @Deprecated(
        "Deprecated since Chrome 91",
        replaceWith = ReplaceWith("Replaced by scripting.executeScript in Manifest V3.")
    )
     fun executeScript(
        // The ID of the tab in which to run the script; defaults to the active tab of the current window.
        tabId: Number?,
        // Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time.
        details: ExtensionTypes.InjectDetails,
        callback: Value1Function<List<Any>?>? = null
    ): Promise<List<Any>?>

    // Retrieves details about the specified tab.
    @PromiseStyleMinVersion(88)
     fun get(
        tabId: Number,
        callback: Value1Function<Tab>? = null
    ): Promise<Tab>

    // Gets details about all tabs in the specified window.
    @PromiseStyleMinVersion(88)
    @LowerEqMV2
    @Deprecated(
        "Deprecated",
        replaceWith = ReplaceWith("Please use tabs.query {windowId: windowId}.")
    )
     fun getAllInWindow(
        // Defaults to the current window.
        windowId: Number?,
        callback: Value1Function<List<Tab>>? = null
    ): Promise<List<Tab>>

    // Gets the tab that this script call is being made from. Returns undefined if called from a non-tab context (for example, a background page or popup view).
    @PromiseStyleMinVersion(88)
     fun getCurrent(callback: Value1Function<Tab?>? = null): Promise<Tab?>

    // Gets the tab that is selected in the specified window.
    @PromiseStyleMinVersion(88)
    @LowerEqMV2
    @Deprecated(
        "Deprecated",
        replaceWith = ReplaceWith("Please use tabs.query {active: true}.")
    )
     fun getSelected(
        // Defaults to the current window.
        windowId: Number?,
        callback: Value1Function<Tab>? = null
    ): Promise<Tab>

    // Gets the current zoom factor of a specified tab.
    // @callback zoomFactor - The tab's current zoom factor.
    @PromiseStyleMinVersion(88)
     fun getZoom(
        // The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
        tabId: Number?,
        callback: Value1Function<Number>? = null
    ): Promise<Number>

    // Gets the current zoom settings of a specified tab.
    // @callback zoomSettings - The tab's current zoom settings.
    @PromiseStyleMinVersion(88)
     fun getZoomSettings(
        // The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
        tabId: Number?,
        callback: Value1Function<ZoomSettings>? = null
    ): Promise<ZoomSettings>

    // Go back to the previous page, if one is available.
    @PromiseStyleMinVersion(88)
    @ChromeMinVersion(72)
     fun goBack(
        // The ID of the tab to navigate back; defaults to the selected tab of the current window.
        tabId: Number?,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Go foward to the next page, if one is available.
    @PromiseStyleMinVersion(88)
    @ChromeMinVersion(72)
     fun goForward(
        // The ID of the tab to navigate forward; defaults to the selected tab of the current window.
        tabId: Number?,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
    // @callback groupId - The ID of the group that the tabs were added to.
    @PromiseStyleMinVersion(88)
    @ChromeMinVersion(72)
     fun group(
        options: GroupOptions,
        callback: Value1Function<Number>? = null
    ): Promise<Number>

    // Highlights the given tabs and focuses on the first of group. Will appear to do nothing if the specified tab is currently active.
    // @callback window - Contains details about the window whose tabs were highlighted.
    @PromiseStyleMinVersion(88)
     fun highlight(
        highlightInfo: HightlightInfo,
        // FIXME:
        callback: Value1Function<Window>? = null
    ): Promise<Window>

    // Injects CSS into a page. Styles inserted with this method can be removed with scripting.removeCSS. For details, see the programmatic injection section of the content scripts doc.
    @PromiseStyleMinVersion(88)
    @LowerEqMV2
    @Deprecated(
        "Deprecated since Chrome 91",
        replaceWith = ReplaceWith("Replaced by scripting.insertCSS in Manifest V3.")
    )
     fun insertCSS(
        // The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
        tabId: Number?,
        // Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time.
        details: ExtensionTypes.InjectDetails,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
    // @callback tasb - Details about the moved tabs.
    @PromiseStyleMinVersion(88)
     fun move(
        // The tab ID or list of tab IDs to move.
        tabIds: NumOrNumArr,
        moveProperties: MoveProperties,
        callback: Value1Function<TabOrTabArr>? = null
    ): Promise<TabOrTabArr>

    // Gets all tabs that have the specified properties, or all tabs if no properties are specified.
    @PromiseStyleMinVersion(88)
     fun query(
        queryInfo: QueryInfo,
        callback: Value1Function<List<Tab>>? = null
    ): Promise<List<Tab>>

    // Reload a tab.
    @PromiseStyleMinVersion(88)
     fun reload(
        // The ID of the tab to reload; defaults to the selected tab of the current window.
        tabId: Number?,
        reloadProperties: ReloadProperties?,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Closes one or more tabs.
    @PromiseStyleMinVersion(88)
     fun remove(
        // The tab ID or list of tab IDs to close.
        tabIds: NumOrNumArr,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Removes from a page CSS that was previously injected by a call to scripting.insertCSS.
    @ChromeMinVersion(87)
    @PromiseStyleMinVersion(88)
    @LowerEqMV2
    @Deprecated(
        "Deprecated since Chrome 91",
        replaceWith = ReplaceWith("Replaced by scripting.removeCSS in Manifest V3.")
    )
     fun removeCSS(
        // The ID of the tab from which to remove the CSS; defaults to the active tab of the current window.
        tabId: Number?,
        // Details of the CSS text to remove. Either the code or the file property must be set, but both may not be set at the same time.
        details: ExtensionTypes.DeleteInjectionDetails,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
    // @callback response - The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback is called with no arguments and runtime.lastError is set to the error message.
    @PromiseStyleMinVersion(99)
     fun sendMessage(
        // The message to send. This message should be a JSON-ifiable object.
        tabId: Number,
        message: Any,
        options: SendMessageOptions?,
        @ChromeMinVersion(99)
        callback: Value1Function<Any>? = null
    ): Promise<Any>

    // Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension.
    // @callback response - The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback is called with no arguments and runtime.lastError is set to the error message.
    @PromiseStyleMinVersion(99)
    @LowerEqMV2
    @Deprecated(
        "Deprecated",
        replaceWith = ReplaceWith("Please use runtime.sendMessage.")
    )
     fun sendRequest(
        tabId: Number,
        request: Any,
        @ChromeMinVersion(99)
        callback: Value1Function<Any>? = null
    ): Promise<Any>

    // Zooms a specified tab.
    @PromiseStyleMinVersion(88)
     fun setZoom(
        // The ID of the tab to zoom; defaults to the active tab of the current window.
        tabId: Number?,
        // The new zoom factor. A value of 0 sets the tab to its current default zoom factor. Values greater than 0 specify a (possibly non-default) zoom factor for the tab.
        zoomFactor: Number,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
    @PromiseStyleMinVersion(88)
     fun setZoomSettings(
        // The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
        tabId: Number?,
        // Defines how zoom changes are handled and at what scope.
        zoomSettings: ZoomSettings,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Removes one or more tabs from their respective groups. If any groups become empty, they are deleted.
    @ChromeMinVersion(88)
     fun ungroup(
        // The tab ID or list of tab IDs to remove from their respective groups.
        tabIds: NumOrNumArr,
        callback: VoidFunction? = null
    ): Promise<Void>

    // Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
    // @callback tab - Details about the updated tab. The url, pendingUrl, title and favIconUrl properties are only included on the tabs.Tab object if the extension has the "tabs" permission or has host permissions for the page.
    @ChromeMinVersion(88)
     fun update(
        tabId: Number?,
        updateProperties: UpdateProperties,
        callback: Value1Function<Tab?>? = null
    ): Promise<Tab?>

    // Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events so as to be notified when a URL is set.
     val onActivated: Events.Event<Value1Function<ActiveInfo>>

    // Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated events so as to be notified when a URL is set.
    @LowerEqMV2
    @Deprecated("Deprecated", replaceWith = ReplaceWith("Please use tabs.onActivated."))
     val onActiveChanged: Events.Event<Value2Function<Number, SelectInfo>>

    // Fired when a tab is attached to a window; for example, because it was moved between windows.
     val onAttached: Events.Event<Value2Function<Number, AttachInfo>>

    // Fired when a tab is created. Note that the tab's URL and tab group membership may not be set at the time this event is fired, but you can listen to onUpdated events so as to be notified when a URL is set or the tab is added to a tab group.
     val onCreated: Events.Event<Value1Function<Tab>>

    // Fired when a tab is detached from a window; for example, because it was moved between windows.
     val onDetached: Events.Event<Value2Function<Number, DetachInfo>>

    // Fired when the highlighted or selected tabs in a window changes.
    @LowerEqMV2
    @Deprecated("Deprecated", replaceWith = ReplaceWith("Please use tabs.onHighlighted."))
     val onHighlightChanged: Events.Event<Value1Function<SelectInfo>>

    // Fired when the highlighted or selected tabs in a window changes.
     val onHighlighted: Events.Event<Value1Function<HightlightInfo>>

    // Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response to the manually-moved tab. This event is not fired when a tab is moved between windows; for details, see tabs.onDetached.
     val onMoved: Events.Event<Value2Function<Number, MoveInfo>>

    // Fired when a tab is closed.
     val onRemoved: Events.Event<Value2Function<Number, RemoveInfo>>

    // Fired when a tab is replaced with another tab due to prerendering or instant.
    // @callback (addedTabId,removedTabId)
     val onReplaced: Events.Event<Value2Function<Number, Number>>

    // Fires when the selected tab in a window changes.
    @LowerEqMV2
    @Deprecated("Deprecated", replaceWith = ReplaceWith("Please use tabs.onActivated."))
     val onSelectionChanged: Events.Event<Value2Function<Number, SelectInfo>>

    // Fired when a tab is updated.
     val onUpdated: Events.Event<Value3Function<Number, ChangeInfo, Tab>>

    // Fired when a tab is zoomed.
     val onZoomChange: Events.Event<Value1Function<ZoomChangeInfo>>

    sealed class TabOrTabArr {
        sealed class Tabb(val value: Tab) : TabOrTabArr()
        sealed class TabArr(val value: List<Tab>) : TabOrTabArr()
    }

    @ChromeMinVersion(46)
    data class MutedInfo(
        // The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed.
        var extensionId: String? = null,
        // Whether the tab is muted (prevented from playing sound). The tab may be muted even if it has not played or is not currently playing sound. Equivalent to whether the 'muted' audio indicator is showing.
        var muted: Boolean,
        // The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed.
        var reason: MutedInfoReason? = null,
    )

    // An event that caused a muted state change.
    @ChromeMinVersion(46)
    enum class MutedInfoReason {
        user,
        capture,
        extension
    }

    data class Tab(
        // Whether the tab is active in its window. Does not necessarily mean the window is focused.
        var active: Boolean,
        // Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted).
        // Equivalent to whether the 'speaker audio' indicator is showing.
        @ChromeMinVersion(45)
        var audible: Boolean? = null,
        // Whether the tab can be discarded automatically by the browser when resources are low.
        @ChromeMinVersion(45)
        var autoDiscardable: Boolean = false,
        // Whether the tab is discarded. A discarded tab is one whose content has been unloaded from memory,
        // but is still visible in the tab strip.
        // Its content is reloaded the next time it is activated.
        var discarded: Boolean,
        // The URL of the tab's favicon.
        // This property is only present if the extension has the "tabs" permission or has host permissions for the page.
        // It may also be an empty string if the tab is loading.
        var favIconUrl: String? = null,
        // Whether the tab is frozen. A frozen tab cannot execute tasks, including event handlers or timers.
        // It is visible in the tab strip and its content is loaded in memory.
        // It is unfrozen on activation.
        @ChromeMinVersion(132)
        var frozen: Boolean = false,
        // The ID of the group that the tab belongs to.
        @ChromeMinVersion(88)
        var groupId: Number = 0,
        // The height of the tab in pixels.
        var height: Number? = 0,
        // Whether the tab is highlighted.
        var highlighted: Boolean,
        // The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a tab may not be assigned an ID;
        // for example, when querying foreign tabs using the sessions API,
        // in which case a session ID may be present.
        // Tab ID can also be set to chrome.tabs.TAB_ID_NONE for apps and devtools windows.
        var id: Number? = 0,
        // Whether the tab is in an incognito window.
        var incognito: Boolean,
        // The zero-based index of the tab within its window.
        var index: Number,
        // The last time the tab became active in its window as the number of milliseconds since epoch.
        @ChromeMinVersion(121)
        var lastAccessed: Number,
        // The tab's muted state and the reason for the last state change.
        @ChromeMinVersion(46)
        var mutedInfo: MutedInfo? = null,
        // The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
        var openerTabId: Number? = null,
        // The URL the tab is navigating to, before it has committed.
        // This property is only present if the extension has the "tabs" permission or has host permissions for the page and there is a pending navigation.
        @ChromeMinVersion(79)
        var pendingUrl: String? = null,
        // Whether the tab is pinned.
        var pinned: Boolean,
        @Deprecated("Whether the tab is selected.", ReplaceWith("Please use tabs.Tab.highlighted."))
        var selected: Boolean = false,
        // The session ID used to uniquely identify a tab obtained from the sessions API.
        var sessionId: String? = null,
        // The tab's loading status.
        var status: TabStatus,
        // The title of the tab. This property is only present if the extension has the "tabs" permission
        // or has host permissions for the page.
        var title: String? = null,
        // The last committed URL of the main frame of the tab. This property is only present if the
        // extension has the "tabs" permission or has host permissions for the page.
        // May be an empty string if the tab has not yet committed. See also Tab.pendingUrl.
        var url: String? = null,
        // The width of the tab in pixels.
        var width: Number? = null,
        // The ID of the window that contains the tab.
        var windowId: Number,
    )

    enum class TabStatus {
        unloaded,
        loading,
        complete
    }

    @ChromeMinVersion(44)
    enum class WindowType {
        normal,
        popup,
        panel,
        app,
        devtools
    }

    // Defines how zoom changes in a tab are handled and at what scope.
    data class ZoomSettings(
        // Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings.
        @ChromeMinVersion(43)
        var defaultZoomFactor: Number?,
        // Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to automatic.
        var mode: ZoomSettingsMode?,
        // Defines whether zoom changes persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
        var scope: ZoomSettingsScope?,
    )

    // Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to automatic.
    @ChromeMinVersion(44)
    enum class ZoomSettingsMode {
        // Zoom changes are handled automatically by the browser.
        automatic,

        // Overrides the automatic handling of zoom changes. The onZoomChange event will still be dispatched, and it is the extension's responsibility to listen for this event and manually scale the page. This mode does not support per-origin zooming, and thus ignores the scope zoom setting and assumes per-tab.
        manual,

        // Disables all zooming in the tab. The tab reverts to the default zoom level, and all attempted zoom changes are ignored.
        disabled
    }

    // Defines whether zoom changes persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
    @ChromeMinVersion(44)
    enum class ZoomSettingsScope {
        // Zoom changes persist in the zoomed page's origin, i.e., all other tabs navigated to that same origin are zoomed as well. Moreover, per-origin zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they are all zoomed to the same zoom factor. The per-origin scope is only available in the automatic mode.
        per_origin,

        // Zoom changes only take effect in this tab, and zoom changes in other tabs do not affect the zooming of this tab. Also, per-tab zoom changes are reset on navigation; navigating a tab always loads pages with their per-origin zoom factors.
        per_tab,
    }

    data class ConnectInfo(
        // Open a port to a specific document identified by documentId instead of all frames in the tab.
        @ChromeMinVersion(106)
        var documentId: String?,
        // Open a port to a specific frame identified by frameId instead of all frames in the tab.
        var frameId: Number?,
        // Is passed into onConnect for content scripts that are listening for the connection event.
        var name: String?,
    )

    data class CreateProperties(
        // Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true.
        var active: Boolean?,
        // The position the tab should take in the window. The provided value is clamped to between zero and the number of tabs in the window.
        var index: Number?,
        // The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
        var openerTabId: Number?,
        // Whether the tab should be pinned. Defaults to false
        var pinned: Boolean?,
        // Whether the tab should become the selected tab in the window. Defaults to true
        @Deprecated("Depreacted", replaceWith = ReplaceWith("Please use active."))
        var selected: Boolean?,
        // The URL to initially navigate the tab to. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page.
        var url: String?,
        // The window in which to create the new tab. Defaults to the current window.
        var windowId: Number?,
    )

    data class GroupOptions(
        // Configurations for creating a group. Cannot be used if groupId is already specified.
        var createProperties: CreateProperties?,
        // The ID of the group to add the tabs to. If not specified, a new group will be created.
        var groupId: Number?,
        // The tab ID or list of tab IDs to add to the specified group.
        var tabIds: NumOrNumArr
    )

    data class HightlightInfo(
        // One or more tab indices to highlight.
        var tabs: NumOrNumArr,
        // The window that contains the tabs.
        var windowId: Number?
    )

    data class MoveProperties(
        // The position to move the window to. Use -1 to place the tab at the end of the window.
        var index: Number,
        // Defaults to the window the tab is currently in.
        var windowId: Number?
    )

    data class QueryInfo(
        // Whether the tabs are active in their windows.
        var active: Boolean?,
        // Whether the tabs are audible.
        @ChromeMinVersion(45)
        var audible: Boolean?,
        // Whether the tabs can be discarded automatically by the browser when resources are low.
        @ChromeMinVersion(54)
        var autoDiscardable: Boolean?,
        // Whether the tabs are in the current window.
        var currentWindow: Boolean?,
        // Whether the tabs are discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content is reloaded the next time it is activated.
        @ChromeMinVersion(54)
        var discarded: Boolean?,
        // Whether the tabs are frozen. A frozen tab cannot execute tasks, including event handlers or timers. It is visible in the tab strip and its content is loaded in memory. It is unfrozen on activation.
        @ChromeMinVersion(132)
        var frozen: Boolean?,
        // The ID of the group that the tabs are in, or tabGroups.TAB_GROUP_ID_NONE for ungrouped tabs.
        @ChromeMinVersion(88)
        var groupId: Number?,
        // Whether the tabs are highlighted.
        var highlighted: Boolean?,
        // The position of the tabs within their windows.
        var index: Number?,
        // Whether the tabs are in the last focused window.
        var lastFocusedWindow: Boolean?,
        // Whether the tabs are muted.
        @ChromeMinVersion(45)
        var muted: Boolean?,
        // Whether the tabs are pinned.
        var pinned: Boolean?,
        // The ID of the Split View that the tabs are in, or tabs.SPLIT_VIEW_ID_NONE for tabs that aren't in a Split View.
        var splitViewId: Number?,
        // The tab loading status.
        var status: TabStatus?,
        // Match page titles against a pattern. This property is ignored if the extension does not have the "tabs" permission or host permissions for the page.
        var title: String?,
        // Match tabs against one or more URL patterns. Fragment identifiers are not matched. This property is ignored if the extension does not have the "tabs" permission or host permissions for the page.
        var url: StringOrStringArr?,
        // The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window.
        var windowId: Number?,
        // The type of window the tabs are in.
        var windowType: WindowType?,
    )

    data class ReloadProperties(
        // Whether to bypass local caching. Defaults to false.
        var bypassCache: Boolean?
    )

    data class SendMessageOptions(
        // Send a message to a specific document identified by documentId instead of all frames in the tab.
        @ChromeMinVersion(106)
        var documentId: String?,
        // Send a message to a specific frame identified by frameId instead of all frames in the tab.
        var frameId: Number?,
    )

    data class UpdateProperties(
        // Whether the tab should be active. Does not affect whether the window is focused (see windows.update).
        var active: Boolean?,
        // Whether the tab should be discarded automatically by the browser when resources are low.
        @ChromeMinVersion(54)
        var autoDiscardable: Boolean?,
        // Adds or removes the tab from the current selection.
        var highlighted: Boolean?,
        // Whether the tab should be muted.
        @ChromeMinVersion(45)
        var muted: Boolean?,
        // The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
        var openerTabId: Number?,
        // Whether the tab should be pinned.
        var pinned: Boolean?,
        // Whether the tab should be selected.
        @Deprecated("Deprecated", replaceWith = ReplaceWith("Please use highlighted."))
        var selected: Boolean?,
        // A URL to navigate the tab to. JavaScript URLs are not supported; use scripting.executeScript instead.
        var url: String?,
    )

    data class ActiveInfo(
        // The ID of the tab that has become active.
        var tabId: Number,
        // The ID of the window the active tab changed inside of.
        var windowId: Number,
    )

    data class SelectInfo(
        // The ID of the window the selected tab changed inside of.
        var windowId: Number
    )

    data class AttachInfo(
        var newPosition: Number,
        var newWindowId: Number
    )

    data class DetachInfo(
        var oldPosition: Number,
        val oldWindowId: Number
    )

    data class MoveInfo(
        var fromIndex: Number,
        var toIndex: Number,
        var windowId: Number
    )

    data class RemoveInfo(
        // True when the tab was closed because its parent window was closed.
        var isWindowClosing: Boolean,
        // The window whose tab is closed.
        var windowId: Number,
    )

    data class ChangeInfo(
        // The tab's new audible state.
        @ChromeMinVersion(45)
        var audible: Boolean?,
        // The tab's new auto-discardable state.
        @ChromeMinVersion(54)
        var autoDiscardable: Boolean?,
        // The tab's new discarded state.
        @ChromeMinVersion(54)
        var discarded: Boolean?,
        // The tab's new favicon URL.
        var favIconUrl: String?,
        // The tab's new frozen state.
        @ChromeMinVersion(132)
        var frozen: Boolean?,
        // The tab's new group.
        @ChromeMinVersion(88)
        var groupId: Number?,
        // The tab's new muted state and the reason for the change.
        @ChromeMinVersion(46)
        var mutedInfo: MutedInfo?,
        // The tab's new pinned state.
        var pinned: Boolean?,
        // The tab's new Split View.
        var splitViewId: Number?,
        // The tab's loading status.
        var status: TabStatus?,
        // The tab's new title.
        @ChromeMinVersion(48)
        var title: String?,
        // The tab's URL if it has changed.
        var url: String?,
    )

    data class ZoomChangeInfo(
        var newZoomFactor: Number,
        var oldZoomFactor: Number,
        var tabId: Number,
        var zoomSettings: ZoomSettings
    )
}